﻿package com.dbm.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;

import org.apache.log4j.Logger;

import com.dbm.model.ConnPoolFactory;
import com.dbm.util.OrderProcess;




/**
 * 订单流水通知工具Dao
 * @author wqying
 *
 */
public class OrderProcessDao {
	Logger log = Logger
			.getLogger(OrderProcessDao.class);
	/**
	 * 将流水信息写入ctl数据库
	 * @param orderProcess
	 * @return
	 * @throws Exception
	 */
	public synchronized boolean addOrderProcess(OrderProcess orderProcess) throws Exception{
		boolean flag = false;
		Connection ctlconn = ConnPoolFactory.getCtlConnection();
		log.info("流水信息orderProcess:\t"+orderProcess);
		String addOrderProcessSql = "insert into TORDERPROCESS" +
				" (ID, ORDERCODE, ORDERID, ORDERTYPE, WAREHOUSECODE, " +
				"PROCESSSTATUS, OPERATORCODE, OPERATORNAME, OPERATETIME, OPERATEINFO, " +
				"REMARK, KEY1, KEY2, SENDFLAG,CUSTOMERID)"
				+"values (?, ?, ?, ?, ?, " +
				"?, ?, ?, ?, ?, " +
				"?, ?, ?, ?,?)";
		PreparedStatement ctlStat = ctlconn.prepareStatement(addOrderProcessSql);
		ctlStat.setString(1, orderProcess.getID());
		ctlStat.setString(2, orderProcess.getORDERCODE());
		ctlStat.setString(3, orderProcess.getORDERID());
		ctlStat.setString(4, orderProcess.getORDERTYPE());
		ctlStat.setString(5, orderProcess.getWAREHOUSECODE());
		ctlStat.setString(6, orderProcess.getPROCESSSTATUS());
		ctlStat.setString(7, orderProcess.getOPERATORCODE());
		ctlStat.setString(8, orderProcess.getOPERATORNAME());
		ctlStat.setString(9, orderProcess.getOPERATETIME());
		ctlStat.setString(10,orderProcess.getOPERATEINFO());
		ctlStat.setString(11,orderProcess.getREMARK());
		ctlStat.setString(12,orderProcess.getKEY1());
		ctlStat.setString(13,orderProcess.getKEY2());
		ctlStat.setString(14,orderProcess.getSENDFLAG());
		ctlStat.setString(15,orderProcess.getCUSTOMERID());
		if(ctlStat.executeUpdate()==1){
			flag = true;
		}
		ctlStat.close();
		ctlconn.close();
		return flag;
	}
}
